package com.itboye.ihomebank.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.ihomebank.R;
import com.itboye.ihomebank.bean.WeixiuXinxiBean;

/**
 * 报修类型(弹出框)
 */
public class LeiXingAdapter02 extends BaseAdapter {
    private Context context;
    WeixiuXinxiBean itemList;
    int type;

    public LeiXingAdapter02(Context context, WeixiuXinxiBean item, int type) {
        this.context = context;
        this.itemList = item;
        this.type = type;
    }

    @Override
    public int getCount() {

        return type==1?itemList.getHousehold().size():itemList.getFurniture().size();
    }

    @Override
    public Object getItem(int position) {
        return type==1?itemList.getHousehold().get(position):itemList.getFurniture().get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Datalist data = new Datalist();
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.item_choose_area, null);
            data.mNameTextView = (TextView) convertView.findViewById(R.id.name);
            convertView.setTag(data);
        } else {
            data = (Datalist) convertView.getTag();
        }
        data.mNameTextView.setText(type==1?itemList.getHousehold().get(position).getName():itemList.getFurniture().get(position).getName());

        return convertView;
    }

    private class Datalist {
        public TextView mNameTextView;
    }


}
